Tutorial Brief

In this tutorial we will cover the following containers and how to use them:

  • ContainerWidget
  • AccordionWidget
  • TabWidget
  • PopupWidget

Import the Library


In [1]:
from IPython.html import widgets

widgets.ContainerWidget


In [2]:
container = widgets.ContainerWidget()

In [3]:
control_1 = widgets.TextWidget(description="Name: ")
control_2 = widgets.TextWidget(description="Email: ")
control_3 = widgets.ButtonWidget(description="Submit")

container.children = [control_1, control_2, control_3]

container

widgets.AccordionWidget


In [4]:
container_1 = container

container_2 = widgets.ContainerWidget()

control_1 = widgets.TextWidget(description="Country: ")
control_2 = widgets.TextWidget(description="State: ")
control_3 = widgets.TextWidget(description="City: ")
control_4 = widgets.ButtonWidget(description="Save")

container_2.children = [control_1, control_2, control_3, control_4]

In [5]:
accordion = widgets.AccordionWidget()
accordion.children = [container_1, container_2]
accordion

In [6]:
accordion.set_title(0, "Personal Information")
accordion.set_title(1, "Location")

widgets.TabWidget


In [7]:
tabs = widgets.TabWidget()
tabs.children = [container_1, container_2]

tabs

In [8]:
tabs.set_title(0, "Personal Information")
tabs.set_title(1, "Location")

widgets.PopupWidget


In [9]:
popup = widgets.PopupWidget(description="Register Now!")
popup.children = [accordion]
popup